import Router from'koa-router';
import userAuthed from '../middleware/userAuthed'
import { BASE_URL } from '../config'
import { getCourseList } from '../service/course'
import { getUploadToken } from '../utils/qiniu'
import { getImageFaceInfo } from '../utils/openAi'

const router = new Router();

/**
 * 用户注册
 */
router.get('/interest-list', userAuthed, async (ctx) => {
  const { id } = ctx.user
  const courseList = await getCourseList(id)
  ctx.success({ courseList }, '')
});

// ai 说脸开始
router.get('/uploadToken', async (ctx) => {
  ctx.success({ token: getUploadToken() }, '')
});

router.get('/faceInfo', async (ctx) => {
  const { img } = ctx.request.query
  const data = await getImageFaceInfo({ url: img })
  ctx.success(data, '')
});
// ai 说脸结束

export const path = `${BASE_URL}/home`
export default router
